package com.sxwl.auth.mapper;

import com.sxwl.pojo.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.session.RowBounds;
import tk.mybatis.mapper.additional.idlist.SelectByIdListMapper;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * @author reading
 * @Description TODO
 * @Date 2020/4/14 16:52
 */
public interface OnlineUserMapper extends Mapper<User>, SelectByIdListMapper<User,String> {
    /**
     * 不推荐这样写 可读性太差了
     * @param list
     * @return
     */
    @Select("<script>" +
            "SELECT\n" +
            "*\n" +
            "from\n" +
            " user\n" +
            "where\n" +
            "email in" +
            "<foreach collection='list' item='item' open='(' separator=',' close=')'>" +
            "#{item} "+
            "</foreach>" +
            "</script>")
    List<User> findOnlineUsers(@Param("list") List<String> list);

}
